package com.zhaopin.springboot;

import com.zhaopin.springboot.server.UserService;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

@SpringBootApplication
public class Application {

    public static void main(String[] args) {
        /**
         * SpringBoot 程序启动后，返回值是 ConfigurableApplicationContext，它也是一个
         * Spring 容器对象
         * 它其它相当于原来 Spring 中启动容器 ClassPathXmlApplicationContext context =
         * new ClassPathXmlApplicationContext("");
         */
        //获取 SpringBoot 程序启动后的 Spring 容器
        ConfigurableApplicationContext context =
                SpringApplication.run(Application.class, args);
        //从 Spring 容器中获取指定 bean 的对象
        UserService userService = (UserService)
                context.getBean("userServiceImpl");
        //调用业务 bean 的方法
        String sayHello = userService.sayHello();
        System.out.println(sayHello);

    }

}
